from sqlalchemy import Column

from apps.db import BaseModel, String


class BorrowerInfo(BaseModel):
    """借款人信息"""
    __tablename__ = 'tb_borrower_info'
    type = Column(String, comment='义务人类型： main: 借款人 sub: 借款人配偶')
    telphone = Column(String, comment='联系电话')
    name = Column(String, comment='借款人名字')
    no = Column(String, comment='借款人在3.0系统中的编号')
    address = Column(String, comment='联系地址')
    cust_id = Column(String)
    cert_type = Column(String)
    cert_no = Column(String, comment='证件号')
    extend_id = Column(String, comment='关联backSideExtendInfo')

    def __init__(self, *args, **kwargs):
        super(BorrowerInfo, self).__init__()
        for attr, value in kwargs.items():
            if attr in self.__column_name_list__() and getattr(self, attr) is None:
                setattr(self, attr, value)
